#include <bits/stdc++.h>
using namespace std;
#define PI 3.1415926
#define   SQUARE(x) ((x)*(x))
//double SQUARE(double x) { return x*x;}

int ans;

//bool cmp(int x1, int x2){return x1<x2;}
void w1()
{
	int m, n, x;
	scanf("%d%d", &m, &n);
 	for(int i=0; i<n; i++){
		scanf("%d", &x);
		if(m >= x){
			ans++;
			m -= x;
		}
 	}
	ans = n - ans;
	printf("%d", ans);

}

int main()
{
	w1();
  return 0;
}
